   package com.javalong.affairs.module.schedule.fragment;

import java.util.HashMap;
import java.util.Map;

import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.javalong.affairs.R;
import com.javalong.affairs.base.constant.BundleKey;
import com.javalong.affairs.base.constant.DataType;
import com.javalong.affairs.base.constant.RequestKey;
import com.javalong.affairs.base.fragment.BaseFragment;
import com.javalong.affairs.base.listener.BaseResponseListener;
import com.javalong.affairs.base.ui.SimplePullRefreshList;
import com.javalong.affairs.base.utils.HttpUtils;
import com.javalong.affairs.base.utils.StringUtils;
import com.javalong.affairs.base.utils.TimeUtils;
import com.javalong.affairs.base.utils.UrlUtils;
import com.lidroid.xutils.ViewUtils;
import com.lidroid.xutils.view.annotation.ViewInject;

public class ScheduleStatisticFragment extends BaseFragment {
	@ViewInject(R.id.lv_statistic)
	private SimplePullRefreshList lv_statistic;

	@Override
	public View onCreateView(LayoutInflater inflater, ViewGroup container,
			Bundle savedInstanceState) {
		View view = inflater.inflate(R.layout.fragment_schedulestatistic, null);
		return view;
	}

	@Override
	public void onViewCreated(View view, Bundle savedInstanceState) {
		super.onViewCreated(view, savedInstanceState);
		ViewUtils.inject(this);
		initData();
	}

	private void initData() {
		HashMap<String, String> coll = (HashMap<String, String>) getActivity()
				.getIntent().getSerializableExtra(BundleKey.IDS);
		HashMap<String, String> coll2 = (HashMap<String, String>) getActivity()
				.getIntent().getSerializableExtra(BundleKey.SECTIONS);
		if (coll == null) {
			return;
		}
		if (coll2 == null) {
			return;
		}
		String ids = StringUtils.join(",", coll.values());
		String sections = StringUtils.join(",", coll2.values());
		String url = UrlUtils.getUrl("Sum", "excel_tree");
		Map<String, Object> params = new HashMap<String, Object>();
		params.put(RequestKey.ID, ids);
		params.put(RequestKey.SECTION, sections);
		params.put(RequestKey.TIMEBEGIN, TimeUtils.getStartTime());
		params.put(RequestKey.TIMEEND, TimeUtils.getEndTime());

		HttpUtils.post(url, params, new BaseResponseListener(
				DataType.SCHEDULETREELIST) {
			@Override
			public void onSuccess(Object obj) {
				super.onSuccess(obj);
				String downloadFilePath = StringUtils.getRandomFilePath();
			}
		});
	}
}
